/*
 * MaxLattice.h
 *
 *  Created on: Sep 9, 2012
 *      Author: Wanderer
 */

#ifndef MAXLATTICE_H_
#define MAXLATTICE_H_

#include "CRF.h"
#include <algorithm>

class MaxLattice {
private:
	struct MaxNode {
		MaxNode* pre;
		int state;
		double weight;
	};
	int length;
	par_t** pars;
	par_t* inipars;
	par_t* finpars;
	quiver_t* input;
	value_t* constrain;
	double* weight;
	MaxNode** path;
	value_t* viterbi;
	bool checkPath(int ip, int state);
public:
	MaxLattice(CRF* model, quiver_t* input);
	MaxLattice(CRF* model, quiver_t* input, value_t* constrain);
	double getWeight(int ip, int i, int j);
	double getInitialWeight(int i);
	double getFinalWeight(int i);
	value_t* best();
	virtual ~MaxLattice();
};

#endif /* MAXLATTICE_H_ */
